package com.tian.controller;

import com.tian.annotation.LoginCheckAnnotation;
import com.tian.common.CommonResult;
import com.tian.dto.ChargePayReqDto;
import com.tian.service.PayBaseService;
import com.tian.service.PrePayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * {@code @description:} TODO
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2025-01-20 9:38
 * {@code @version:} 1.0
 */
@Slf4j
@RestController
@RequestMapping("/paymment/prepay")
public class PrePayController {
    @Resource
    private PrePayService prePayService;
    @Autowired
    private PayBaseService payBaseService;
    @LoginCheckAnnotation
    @PostMapping("/")
    public CommonResult<String> prePay(@RequestBody ChargePayReqDto chargePayReqDto) {
        try {
            return prePayService.doPay(chargePayReqDto);
        } catch (Exception e) {
            log.error("预支付接口异常", e);
            return CommonResult.failed();
        }
    }
    @GetMapping("/test")
    public String test() {
        return payBaseService.test();
    }
}
